package com.hospital.Entity;

import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by wangjun on 2015/5/25.
 */
public class MsgItem {

        private int messageId;
        private int sendingId;
        private boolean voiceAlert;
        private int jobTypeId;
        private int jobId;
        private Date dateCreated;
        private String messageTitle;
        private String message;
        private int messageTypeId;
        private String messageType;
        private boolean read;
        private boolean vibrate;
        private int targetId;

        public int getMessageId() {
            return messageId;
        }

        public void setMessageId(int messageId) {
            this.messageId = messageId;
        }


        public static MsgItem jsonToMsgItem(JSONObject obj) {
            MsgItem msg = new MsgItem();
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                msg.setMessageId(obj.getInt("MessageId"));
                msg.setSendingId(obj.getInt("SendingId"));
                msg.setVoiceAlert(obj.getBoolean("VoiceAlert"));
                msg.setJobTypeId(obj.getInt("JobTypeId"));
                msg.setJobId(obj.getInt("JobId"));
                msg.setDateCreated(sdf.parse(obj.getString("DateCreated")));
                msg.setMessageTitle(obj.getString("MessageTitle"));
                msg.setMessage(obj.getString("Message"));
                msg.setMessageTypeId(obj.getInt("MessageTypeId"));
                msg.setMessageType(obj.getString("MessageType"));
                msg.setRead(obj.getBoolean("Read"));
                msg.setVibrate(obj.getBoolean("Vibrate"));
                msg.setTargetId(obj.getInt("TargetId"));
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }


            return msg;
        }

        public int getSendingId() {
            return sendingId;
        }

        public void setSendingId(int sendingId) {
            this.sendingId = sendingId;
        }

        public boolean isVoiceAlert() {
            return voiceAlert;
        }

        public void setVoiceAlert(boolean voiceAlert) {
            this.voiceAlert = voiceAlert;
        }

        public int getJobTypeId() {
            return jobTypeId;
        }

        public void setJobTypeId(int jobTypeId) {
            this.jobTypeId = jobTypeId;
        }

        public int getJobId() {
            return jobId;
        }

        public void setJobId(int jobId) {
            this.jobId = jobId;
        }

        public Date getDateCreated() {
            return dateCreated;
        }

        public void setDateCreated(Date dateCreated) {
            this.dateCreated = dateCreated;
        }

        public String getMessageTitle() {
            return messageTitle;
        }

        public void setMessageTitle(String messageTitle) {
            this.messageTitle = messageTitle;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public int getMessageTypeId() {
            return messageTypeId;
        }

        public void setMessageTypeId(int messageTypeId) {
            this.messageTypeId = messageTypeId;
        }

        public String getMessageType() {
            return messageType;
        }

        public void setMessageType(String messageType) {
            this.messageType = messageType;
        }

        public boolean isRead() {
            return read;
        }

        public void setRead(boolean read) {
            this.read = read;
        }

        public boolean isVibrate() {
            return vibrate;
        }

        public void setVibrate(boolean vibrate) {
            this.vibrate = vibrate;
        }

        public int getTargetId() {
            return targetId;
        }

        public void setTargetId(int targetId) {
            this.targetId = targetId;
        }
    }


